home *** CD-ROM | disk | FTP | other *** search
/ The Utilities Experience / The Utilities Experience - Volume 1.iso / software / comms / voodoo / contrib / smtpsend / smtpsend.rexx
OS/2 REXX Batch file  |  1995-12-06  |  2KB  |  79 lines

  1. /*) SMTPSend v1.0 by Josef Faulkner (panther@gate.net) IRC: Josef
  2. \\\ Simple SMTP mail sender.  Specify your SMTP host below.
  3. (*/
  4.  
  5. SMTPHost   = 'cyber.gate.net'
  6.  
  7. options results
  8. if ~show('L','rexxsupport.library') then if
  9. ~addlib('rexxsupport.library',0,-30,0) then exit(20)
  10. parse arg file
  11. file=strip(file)
  12. if ~showlist(H,'TCP') then address command 'mount TCP: from
  13. amitcp:devs/inet-mountlist'
  14. if ~showlist(H,'TCP') then address command 'mount TCP:'
  15. if showlist(H,'TCP') then do
  16.     foundsubj=0
  17.     foundto=0
  18.     foundfrom=0
  19.     call open(1,file,r)
  20.     do until (eof(1))|(strip(text)='')
  21.         text=readln(1)
  22.         select
  23.             when upper(word(text,1))='SUBJECT:' then do
  24.                 parse var text .' 'subj
  25.                 subj=strip(subj)
  26.                 foundsubj=1
  27.             end
  28.             when upper(word(text,1))='TO:' then do
  29.                 parse var text .' 'to
  30.                 to=strip(to)
  31.                 foundto=1
  32.             end
  33.             when upper(word(text,1))='FROM:' then do
  34.                 parse var text .'<'from'>'.
  35.                 from=strip(from)
  36.                 foundfrom=1
  37.             end
  38.             otherwise nop
  39.         end
  40.     end
  41.     if (foundto)&(foundfrom) then do
  42.         call close(1)
  43.         call open(1,'tcp:'smtphost'/25',w)
  44.         call writeln(1,'HELO')
  45.         call writeln(1,'MAIL FROM: '||from)
  46.         call writeln(1,'RCPT TO: '||to)
  47.         call writeln(1,'DATA')
  48.         call open(2,file,r)
  49.         do until eof(2)
  50.             text=readln(2)
  51.             if text='.' then text=' .'
  52.             call writeln(1,text)
  53.         end
  54.         call close(2)
  55.         call writeln(1,'.')
  56.         call writeln(1,'QUIT')
  57.         call close(1)
  58.         address command 'Requestchoice title="SMTPSend" BODY="Mail Sent."
  59. GADGETS="Ok" >NIL:'
  60.     end
  61.     else do
  62.         select
  63.             when ~((foundto)&(foundfrom)) then address command 'Requestchoice
  64. title="SMTPSend" BODY="Mail NOT sent.  *nTo: and From: not specified."
  65. GADGETS="Ok" >NIL:'
  66.             when ~(foundfrom) then address command 'Requestchoice title="SMTPSend"
  67. BODY="Mail NOT sent.  *nFrom: not specified." GADGETS="Ok" >NIL:'
  68.             when ~(foundto) then address command 'Requestchoice title="SMTPSend"
  69. BODY="Mail NOT sent.  *nTo: not specified." GADGETS="Ok" >NIL:'
  70.             otherwise address command 'Requestchoice title="SMTPSend" BODY="Mail NOT
  71. sent.  *nArexx logic error." GADGETS="Ok" >NIL:'
  72.         end
  73.     end
  74. end
  75. else address command 'Requestchoice title="SMTPSend" BODY="Mail NOT sent. 
  76. *nCouldn''t mount TCP:" GADGETS="Ok" >NIL:'
  77. exit
  78.  
  79.